package com.kasinf.sample.mq.redis.controller;

import com.kasinf.framework.cache.mq.RedisMQTemplate;
import com.kasinf.framework.cache.utils.RedisUtils;
import com.kasinf.sample.mq.redis.message.TestMessage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : Kaiser
 * @Date: 2025/5/23  14:25
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private RedisMQTemplate redisMQTemplate;

    @PostMapping("/publish")
    public String publish(String message) {
        RedisUtils.publish("test-topic", message);
        return "ok";
    }

    @PostMapping("/produce")
    public String produce(String message) {
        TestMessage testMessage = new TestMessage("123465", message);
        redisMQTemplate.send(testMessage);
        return "ok";
    }
}
